package com.ruoyi.jjyh.controller;

import java.util.List;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.jjyh.domain.JjyhCourierServices;
import com.ruoyi.jjyh.service.IJjyhCourierServicesService;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 物流档案Controller
 * 
 * @author ruoyi
 * @date 2020-11-24
 */
@Controller
@RequestMapping("/jjyh/services")
public class JjyhCourierServicesController extends BaseController
{
    private String prefix = "jjyh/services";

    @Autowired
    private IJjyhCourierServicesService jjyhCourierServicesService;

    @RequiresPermissions("jjyh:services:view")
    @GetMapping()
    public String services()
    {
        return prefix + "/services";
    }

    /**
     * 查询物流档案列表
     */
    @RequiresPermissions("jjyh:services:list")
    @PostMapping("/list")
    @ResponseBody
    public TableDataInfo list(JjyhCourierServices jjyhCourierServices)
    {
        startPage();
        List<JjyhCourierServices> list = jjyhCourierServicesService.selectJjyhCourierServicesList(jjyhCourierServices);
        return getDataTable(list);
    }

    /**
     * 导出物流档案列表
     */
    @RequiresPermissions("jjyh:services:export")
    @Log(title = "物流档案", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    @ResponseBody
    public AjaxResult export(JjyhCourierServices jjyhCourierServices)
    {
        List<JjyhCourierServices> list = jjyhCourierServicesService.selectJjyhCourierServicesList(jjyhCourierServices);
        ExcelUtil<JjyhCourierServices> util = new ExcelUtil<JjyhCourierServices>(JjyhCourierServices.class);
        return util.exportExcel(list, "services");
    }

    /**
     * 新增物流档案
     */
    @GetMapping("/add")
    public String add()
    {
        return prefix + "/add";
    }

    /**
     * 新增保存物流档案
     */
    @RequiresPermissions("jjyh:services:add")
    @Log(title = "物流档案", businessType = BusinessType.INSERT)
    @PostMapping("/add")
    @ResponseBody
    public AjaxResult addSave(JjyhCourierServices jjyhCourierServices)
    {
        return toAjax(jjyhCourierServicesService.insertJjyhCourierServices(jjyhCourierServices));
    }

    /**
     * 修改物流档案
     */
    @GetMapping("/edit/{id}")
    public String edit(@PathVariable("id") String id, ModelMap mmap)
    {
        JjyhCourierServices jjyhCourierServices = jjyhCourierServicesService.selectJjyhCourierServicesById(id);
        mmap.put("jjyhCourierServices", jjyhCourierServices);
        return prefix + "/edit";
    }

    /**
     * 修改保存物流档案
     */
    @RequiresPermissions("jjyh:services:edit")
    @Log(title = "物流档案", businessType = BusinessType.UPDATE)
    @PostMapping("/edit")
    @ResponseBody
    public AjaxResult editSave(JjyhCourierServices jjyhCourierServices)
    {
        return toAjax(jjyhCourierServicesService.updateJjyhCourierServices(jjyhCourierServices));
    }

    /**
     * 删除物流档案
     */
    @RequiresPermissions("jjyh:services:remove")
    @Log(title = "物流档案", businessType = BusinessType.DELETE)
    @PostMapping( "/remove")
    @ResponseBody
    public AjaxResult remove(String ids)
    {
        return toAjax(jjyhCourierServicesService.deleteJjyhCourierServicesByIds(ids));
    }
}
